/*****************************************************************************
 *
 * Copyright (C) 2003 CSHCN, University of Maryland.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Authors: Dionysus Blazakis <dblaze@umd.edu>
 *          Jonathan Polley <jpolley@umd.edu>
 *          Dan Rusk <drusk@umd.edu>
 *          Manish Karir <karir@umd.edu>
 *
 *****************************************************************************/

#ifndef MAODV_MACT_H
#define MAODV_MACT_H

#ifndef NS_NO_GLOBALS
#include <endian.h>

#include "defs.h"
#include "multicast_routing_table.h"

/* MACT Flags: */
#define MACT_JOIN   0x10
#define MACT_PRUNE  0x08
#define MACT_GRPL   0x04
#define MACT_UPDATE 0x02
#define MACT_REBOOT 0x01

typedef struct _mact_t {
    u_int8_t type;
#  if __BYTE_ORDER == __LITTLE_ENDIAN
    u_int8_t res1:3;
    u_int8_t r:1;
    u_int8_t u:1;
    u_int8_t g:1;
    u_int8_t p:1;
    u_int8_t j:1;
#  elif __BYTE_ORDER == __BIG_ENDIAN
    u_int8_t j:1;
    u_int8_t p:1;
    u_int8_t g:1;
    u_int8_t u:1;
    u_int8_t r:1;
    u_int8_t res1:3;
#  else
#   error "Adjust your <bits/endian.h> defines"
#  endif
    u_int8_t res2;
    u_int8_t hcnt;
    u_int32_t grp_addr;
    u_int32_t src_addr;
    u_int32_t src_seqno;
} mact_t;

#define MACT mact_t
#define MACT_SIZE sizeof(MACT)

#endif				/* NS_NO_GLOBALS */

#ifndef NS_NO_DECLARATIONS
MACT *mact_create(u_int8_t flags,
        u_int8_t hcnt,
        u_int32_t src_addr,
        u_int32_t grp_addr);

void mact_send(u_int8_t flags,
        u_int8_t hcnt,
        u_int32_t grp_addr,
        u_int32_t dst_addr,
        int ttl);

void mact_mcast(u_int8_t flags,
        u_int8_t hcnt,
        u_int32_t grp_addr,
        int ttl);

void mact_process(MACT *mact);

mrt_nexthop_t *mact_activate_best_upstream(mrt_table_t *mrt);
void mact_make_downstream_leader(mrt_table_t *mrt);


#endif				/* NS_NO_DECLARATIONS */

#endif				/* MAODV_MACT_H */
